#ifndef _MOTASP_LIB_H_
#define _MOTASP_LIB_H_
/****************************************************************************
 *Copyright(C),2024, Ningbo Tuopu Group Co., Ltd.
 *FileName:   MotAsp_Lib_I.h
 *Date:       2024-12-16 19:03:04
 *Author:     TianGui.Wang
 *Version:    0
 *Path:       
 *Description:
 ****************************************************************************/
/****************************************************************************/
/*                             Include area                                 */
/****************************************************************************/
#include "MotAsp/MotAsp_Base.h"
/****************************************************************************/
/*                             Definition area                              */
/****************************************************************************/
    
/****************************************************************************/
/*                             Typedef area                                 */
/****************************************************************************/
/*The four most basic signals for each resolve, as well as the total number of signals*/
typedef enum{
    MotAsp_Lib_SIN_0 = 0u,                     /*SIN-*/                    
    MotAsp_Lib_SIN_1,                          /*SIN+*/                 
    MotAsp_Lib_COS_0,                          /*COS-*/                 
    MotAsp_Lib_COS_1,                          /*COS+*/             
    MotAsp_Lib_SIN_COS_SIG_NUM,
}MotAsp_Lib_SinCos_SIG_NUM;

typedef enum{
    MotAsp_Lib_SiCo_Sin,                       /*sin*/                                     
    MotAsp_Lib_SiCo_Cos,                       /*cos*/                                 
    MotAsp_Lib_SiCo_NUM,                                                    
}MotAsp_Lib_SiCo_STATE;

/*The structure of the sine and cosine signal used in the calculation*/
typedef struct{
    int16_T Sin;                       /*sin*/
    int16_T Cos;                       /*cos*/
}MotAsp_Lib_SinCos_INFO;

typedef struct MotAsp_Lib{
    int16_T Max;                       /*max*/
    int16_T Min;                       /*min*/
}MotAsp_Lib_DATA_LIMIT_S16;


/**************************************************Signal line diagnostics*****************************************************/
/*Diagnostic information for MPS's signal lines*/
typedef enum{
    MOTASP_Lib_F_NORMAL = 0u,         /*IDLE*/                                          
    MOTASP_Lib_F_OP,                  /*OP*/                                      
    MOTASP_Lib_F_SG,                  /*SG*/                                      
    MOTASP_Lib_F_SB,                  /*SB*/                                      
    MOTASP_Lib_F_ERR,                 /*ERR*/                          
}MotAsp_Lib_FAULT_TYPE;

/*Voltage acquisition range information of the resolver signal line*/
typedef struct{
    uint16_T Min_V;                     /*The minimum allowable AD voltage value*/                          
    uint16_T Min_Allow;                 /*The minimum AD voltage value*/                          
    uint16_T Max_Allow;                 /*The maximum AD voltage value*/                                      
    uint16_T Max_V;                     /*The maximum allowable AD voltage value*/                                              
}MotAsp_Lib_SIG_V_RANGE_TYPE;

/*Count struct information*/
typedef struct{
    uint8_T Sig;                    /*sign*/                      
    uint32_T cnt;                   /*Count*/                              
    uint32_T CNT;                   /*Count limit*/                              
}MotAsp_Lib_CNT_STATUS;

/*Basic information on the diagnosis of resolver signal lines*/
typedef struct{
    MotAsp_Lib_SIG_V_RANGE_TYPE V_Range;      /*-   The range of AD voltage values for the sin+, cos+, sin-, and cos- signals*/                                      

    uint16_T SinCos_V;                          /*-   Acquisition AD values of sin+, cos+, sin-, and cos- signals*/                                          
    MotAsp_Lib_CNT_STATUS SiCo_F;             /*-   sin+, cos+, sin-, cos- signal counting structures*/                                      
}MotAsp_Lib_SIG_DIAG_BASIC_STATUS;                                                                  
/*******************************_STATUS*******************Signal line diagnostics*****************************************************/



/**************************************Diagnosis of sine and cosine waveform signals*******************************************/
/*Voltage acquisition range information of the resolver signal line*/
typedef struct{
    int16_T Limit_Min;              /*The actual minimum*/                                     
    int16_T Limit_Mid;              /*Intermediate or central value*/                     
    int16_T Limit_Max;              /*The actual minimum*/                         
    int16_T Diff_V;                 /*The hysteresis interval of the upper and lower bounds*/                                     
}MotAsp_Lib_SINCOS_CALIB_PARA_STATUS;

/*Basic information on the diagnosis of resolver signal lines*/
typedef struct{
    MotAsp_Lib_SINCOS_CALIB_PARA_STATUS Limit_D;          /*-     sin, cos signal counting structures*/                                  

    MotAsp_Lib_SinCos_INFO SiCo_Diff;                     /*-     SIN and COS signals     */                                                  
    MotAsp_Lib_CNT_STATUS SiCs_DF;                        /*-     Acquisition AD values of sin+, cos, sin,*/                                      
}MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS;
/**************************************Diagnosis of sine and cosine waveform signals*******************************************/



/**********************The median average filtering of the collected SIN and COS signals was carried out***********************/
typedef struct {
    int16_T Calc_Gain;                 /*-    Sin and Cos collect and calculate the magnification or gain of the original signal*/
    uint16_T Simp_Arr_CNT;              /*-    The length of the array*/
    int16_T *Simp_Arr_Dislay;          /*-    The pointer to the signal history data array of Sin and Cos*/

    uint16_T Limit_Calib;               /*-    Effective limits for Sin+, Cos+, Sin-, Cos-*/
    uint16_T State;                     /*-    The signal validity status of Sin+, Cos+, Sin-, and Cos-*/
    uint16_T Simp0;                     /*-    Sin-、Cos-*/
    uint16_T Simp1;                     /*-    Sin+、Cos+*/
    int16_T Simp;                      /*-    Sin、Cos ；For example : Simp_Sin = Gain * (Sin+ - Sin-);*/
    int16_T Simp_Last;                 /*-    The Sin、Cos result of the last Simp*/
    uint16_T Simp_Arr_Cnt;              /*-    The length of the array*/
    int16_T FILTER;                    /*-    The Sin、Cos current filtering results*/
}MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS;
/**********************The median average filtering of the collected SIN and COS signals was carried out***********************/

/**********************                 The algorithm processing of SIN and COS to find the 
 *                                   maximum and minimum values in the whole acquisition process        ***********************/
typedef struct {
    int16_T Val;           /*-    The median value of the calculation*/                              
    int16_T Max;           /*-    maximum*/                                          
    int16_T Min;           /*-    minmum*/                                  
}MotAsp_Lib_SINCOS_LIMIT_DATA;

typedef struct {
    int16_T Center_Point;                           /*-    Center point*/                                                                                                
    int16_T Amplitude;                              /*-    Amplitude*/                                                                                             
                                                 
    MotAsp_Lib_SINCOS_LIMIT_DATA Interim;          /*-    The collected information and the maximum and minimum values  */                                                                                                                                                 
    MotAsp_Lib_DATA_LIMIT_S16 Curr;                /*-    The current information and the maximum and minimum values ...*/                                                                                                                    
    MotAsp_Lib_CNT_STATUS Updata_Max;              /*-    A count structure where the maximum value is exceeded         */                                                                                                   
    MotAsp_Lib_CNT_STATUS Updata_Min;              /*-    A count structure where the minimum value is exceeded         */                                                                                                                                                  
    uint16_T sico_Beyong;                            /*-    The maximum and minimum simultaneous overrun status           */                                                                                                                       
}MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS;

typedef struct {
    int16_T Calc_G;                        /*-     Gain */                                                  
    int16_T Calc_molecule0;                /*-     molecule- */
    int16_T Calc_numerator0;               /*-     denominator-*/

    uint8_T Init_Sig;
    int32_T Last_Simp;

    int16_T Simp;                          /*-     The maximum or minimum value of cos and sin*/                                          
    int16_T result;                        /*-     The result after compensation            */                          
}MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS;
/**********************                 The algorithm processing of SIN and COS to find the 
 *                                   maximum and minimum values in the whole acquisition process        ***********************/

/***********************************************************The maximum and minimum values of sin(cos) are calculated by cos(sin), and the 
          center point and gain are calculated, and the proportional values of the current sin(cos) are obtained
 * *******************************************************************/
typedef enum
{
    MotAsp_Lib_CALI_IDLE = 0U,                  /*Idle state*/                               
    MotAsp_Lib_CALI_START,                      /*Start the operation, collect enough data, and analyze*/                           
    MotAsp_Lib_CALI_CCURVE_PEAK,                /*The highest peak of the waveform trajectory*/                                   
    MotAsp_Lib_CALI_CCURVE_UP,                  /*The lowest peak of the waveform trajectory*/                               
    MotAsp_Lib_CALI_CCURVE_DOWN,                /*The waveform trajectory is in decline*/                           
    MotAsp_Lib_CALI_CCURVE_VELLEY,              /*The waveform trajectory is on the rise*/                               
}MotAsp_Lib_CALI_STATE;

typedef struct {
    uint16_T Ratio;                                        /*-   The value of a quarter of each circle, such as:65536 / 4 = 16384*/                                                       
    MotAsp_Lib_SINCOS_LIMIT_DATA Init;                   /*-   The initial maximum and minimum values of sin(cos).  */                                                                   
    uint16_T Arr_CNT;                                      /*-   How much of this data is prepared is calculated after that */                                                           
 
    MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS max;    /*-   The maximum value of this signal sin(cos) is the PI structure             */                                   
    MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS min;    /*-   The minimum value of this signal sin(cos) is the PI structure */
    MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS MIA;      /*-   Detects the maximum or minimum value of the signal's sin(cos).            */                                           
 
    int16_T Simp;                                         /*-   sin(cos) is the current value of the collection                           */                                                   
    MotAsp_Lib_CALI_STATE State;                         /*-   Operational status                                 */                                       
    int16_T Simp_Another;                                 /*-   cos(sin), the signal variable used for reference by the signal under test */                                                   
    uint16_T Arr_Cnt;                                      /*-   The number of times the current count is counted                */ 

    uint8_T Pi_Clac_En;

    uint8_T Init_Sig;
    int16_T Gain;
    int16_T Offer;                     
 
    int16_T Center;                                       /*Center point*/   
    int16_T Result;                                       /*-   The correction algorithm calculates the value of the sin(cos) signal      */                       
}MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS;
/***********************************************************The maximum and minimum values of sin(cos) are calculated by cos(sin), and the 
          center point and gain are calculated, and the proportional values of the current sin(cos) are obtained
 * *******************************************************************/

/*******************************************The angular signal value calculated by tangent**********************************************/
typedef enum
{
    MotAsp_Lib_COORDINATE_BASIC0    = 8U,               /*Calculate the basic parameters of the waveform trajectory*/                           
    MotAsp_Lib_COORDINATE_BASIC1    = 12U,              /*Calculate the basic parameters of the waveform trajectory*/                           
    MotAsp_Lib_COORDINATE_BASIC2    = 2U,               /*Calculate the basic parameters of the waveform trajectory*/                           
    MotAsp_Lib_COORDINATE_BASIC3    = 1U,               /*Calculate the basic parameters of the waveform trajectory*/                           
}MotAsp_Lib_COORDINATE_BASIC_STATE;

typedef enum
{   
    MotAsp_Lib_COORDINATE_QUADI     = 10U,            /*First Quadrant*/                                                             
    MotAsp_Lib_COORDINATE_QUADII    = 2U,             /*Second quadrant*/                                             
    MotAsp_Lib_COORDINATE_QUADIII   = 0U,             /*Third Quadrant*/                                         
    MotAsp_Lib_COORDINATE_QUADIV    = 8U,             /*Fourth Quadrant*/                                 
    MotAsp_Lib_COORDINATE_CENTER    = 15U,            /*Be at the center point*/                                 
    MotAsp_Lib_COORDINATE_EAST      = 11U,            /*EAST */                                     
    MotAsp_Lib_COORDINATE_NORTH     = 14U,            /*NORTH*/                                 
    MotAsp_Lib_COORDINATE_SOUTH     = 12U,            /*SOUTH*/                                                 
    MotAsp_Lib_COORDINATE_WEST      = 3U,             /*WEST */                                                             
}MotAsp_Lib_COORDINATE_FACTOR_STATE;

typedef struct
{
    uint16_T Quad_I;           /*First Quadrant*/                             
    uint16_T Quad_II;          /*Second quadrant*/                                    
    uint16_T Quad_III;         /*Third Quadrant*/                                     
    uint16_T Quad_IV;          /*Fourth Quadrant*/                                                
}MotAsp_Lib_COORDINATE_BASIC_ANGLE_STATE;

typedef struct { 
    uint16_T ArcTan45_Arr_Num;                                         /*-   The size of the tangent array    */                                               
    uint16_T Degrees_90;                                               /*-   What is the value of 90° */               

    MotAsp_Lib_COORDINATE_FACTOR_STATE Coordinate_Factor;            /*-   The parameter of the curve circle                           */                                   
    MotAsp_Lib_SinCos_INFO Calib;                                    /*-   Corrected SIN and COS signals                       */           
    MotAsp_Lib_COORDINATE_BASIC_ANGLE_STATE Basic;                   /*-   The starting value of the x,y axis of the trajectory circle */                           
 
    uint16_T Angle_Comp;
    uint16_T Baisc_V;
    uint8_T Quadrant;                                                  /*-   Quadrants of the x-and y-axis of the trajectory circle      */                                               
    uint16_T Angle;                                                    /*-   The calculated angle                                        */                   
}MotAsp_Lib_SINCOS_TRACK_COORDINATE_STATUS;
/*******************************************The angular signal value calculated by tangent**********************************************/

/*********************************************************
 * 
 * Calculate the corresponding amount of angle accumulation as well as the velocity of the angle 
 * 
 * *********************************************************************/
typedef struct {
    uint8_T Poles;
    uint16_T Degrees_180;                 /*-     What is the value of 180° */                                                                                                                          
    uint16_T Degrees_360;                 /*-     What is the value of 360° */                                                                                                                               
                                                                                       
    uint16_T Calib_Angle;                 /*-     The calculated angle                      */
    uint16_T Last_Calib_Angle;            /*-     The Angle value of the last time          */                                                                                                                                    
    int16_T Incr_Angle;                  /*-     The value that increases each time        */
    int32_T Delay0_Angle;                /*-     The Angle value of the last time          */ 
    int32_T Delay1_Angle;
    int32_T Delay2_Angle;

    uint8_T Init_Sig;

    uint16_T M_Angle;
    int32_T Angle;                       /*-     All angles increase and                   */                                                                                                                                                                                                                     
    int16_T spd;                         /*-     Angles that increase with each run        */                                                                                                                     
}MotAsp_Lib_ANGLE_INCREMENT_STAUTS;
/*********************************************************
 * 
 * Calculate the corresponding amount of angle accumulation as well as the velocity of the angle 
 * 
 * *********************************************************************/

/**********************************************************MPS********************************************************************/

typedef struct {
    uint8_T Init_Sig;
    MotAsp_Lib_SIG_DIAG_BASIC_STATUS D_SiCo_i[MotAsp_Lib_SIN_COS_SIG_NUM];      /*Diagnose the status of the sensor signal*/ 
    MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS D_sico;                                 /*Diagnose the status of the cos \ sin INFO*/    
    MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS F_Sico[MotAsp_Lib_SiCo_NUM];    /*Differential filtering of sensor signals*/                                                                
    MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS C_SiCo[MotAsp_Lib_SiCo_NUM];            /*Compensation of sensor signals*/                                                                    
    MotAsp_Lib_SINCOS_TRACK_COORDINATE_STATUS Arctan;                           /*The arctangent of the sensor signal*/                                                            
    MotAsp_Lib_ANGLE_INCREMENT_STAUTS Sp;                                       /*The velocity of the sensor signal as well as the position signal are calculated*/                                        
}MotAsp_Lib_MPS_STAUTS;
/**********************************************************MPS********************************************************************/


/****************************************************************************/
/*                             Local data at RAM                            */
/****************************************************************************/

/****************************************************************************/
/*                             Global data at RAM                           */
/****************************************************************************/

/****************************************************************************/
/*                        Global data at RAM declare area                   */
/****************************************************************************/

/****************************************************************************/
/*                             Local data at ROM                            */
/****************************************************************************/

/****************************************************************************/
/*                             Global data at ROM                           */
/****************************************************************************/

/****************************************************************************/
/*                        Global data at ROM declare area                   */
/****************************************************************************/

/****************************************************************************/
/*                        Local function declare area                       */
/****************************************************************************/

/****************************************************************************/
/*                        Global function declare area                      */
/****************************************************************************/

/****************************************************************************/
/*                      Global function Implementation area                 */
/****************************************************************************/
/*
*Function :                                  MotAsp_Lib_Com_Avg_Mid                      
*Brief    :  The median value of the largest and smallest is calculated, and the callback is made                   
*Para     :                        MotAsp_Lib_SINCOS_LIMIT_DATA *MotAsp_Lib_Obj 
                                   typedef struct {
                                             sint16 Val;    -The median value of the calculation
                                             sint16 Max;    -maximum
                                             sint16 Min;    -minmum
                                             }MotAsp_Lib_SINCOS_LIMIT_DATA;                       
*Return   :                                          NULL                                
 */
void MotAsp_Lib_Com_Avg_Mid(MotAsp_Lib_SINCOS_LIMIT_DATA *MotAsp_Lib_Obj);

/*
*Function :                                MotAsp_Lib_UpdataMinMax              
*Brief    :     Query the collected values of sin, cos, or other trajectories compared with the 
               previous maximum and minimum values, and feedback the maximum and minimum values                      
*Para     :                   MotAsp_Lib_SIG_DIAG_BASIC_STATUS *MotAsp_Lib_Obj    
                                   typedef struct {
                                             sint16 Val;    -The median value of the calculation
                                             sint16 Max;    -maximum
                                             sint16 Min;    -minmum
                                             }MotAsp_Lib_SINCOS_LIMIT_DATA;                      
*Return   :                                   NULL                              
 */
void MotAsp_Lib_UpdataMinMax(MotAsp_Lib_SINCOS_LIMIT_DATA *MotAsp_Lib_Obj);

/*
*Function :                                MotAsp_Lib_Cnt_UpdataMinMax                 
*Brief    :        Check whether the maximum and minimum values of the collection are updated,
               compare them with the size of the set limit center point to the amplitude, check whether 
               there is any exceedance, and record the number of times, status, and exceeded values                          
*Para     :                        MotAsp_Lib_SIG_DIAG_BASIC_STATUS *MotAsp_Lib_Obj 
                         typedef struct {
                                   sint16 Center_Point;                         -Center point                  
                                   sint16 Amplitude;                            -Amplitude

                                   MotAsp_Lib_SINCOS_LIMIT_DATA Interim;        -The collected information and the maximum and minimum values  
                                   MotAsp_Lib_DATA_LIMIT_S16 Curr;              -The current information and the maximum and minimum values ...   
                                   MotAsp_Lib_CNT_STATUS Updata_Max;            -A count structure where the maximum value is exceeded           
                                   MotAsp_Lib_CNT_STATUS Updata_Min;            -A count structure where the minimum value is exceeded                         
                                   uint16 sico_Beyong;                          -The maximum and minimum simultaneous overrun status                         
                                   }MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS;                                                           
*Return   :                                   NULL                                     
 */
void MotAsp_Lib_Cnt_UpdataMinMax(MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS *MotAsp_Lib_Obj);

/*
*Function :                             MotAsp_Lib_Mps_Pi_Calc                      
*Brief    :              PI compensation algorithm for the maximum and minimum values of sin and cos                         
*Para     :              MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS *MotAsp_Lib_Obj        
                              typedef struct {
                              sint16 Simp;                          -The maximum or minimum value of cos and sin
                              sint16 Calc_G;                        -Gain
                              sint16 Calc_molecule0;                -molecule-
                              sint16 Calc_numerator0;               -denominator-
                              sint16 result;                        -The result after compensation            
                              }MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS;                         
*Return   :                                   NULL                                      
 */
void MotAsp_Lib_Mps_Pi_Calc(MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS *MotAsp_Lib_Obj);

/*
*Function :                                MotAsp_Lib_Mps_SimpleFault                 
*Brief    :               Diagnostic detection of the status of the four wires of sin+, sin-, cos+, and cos-                         
*Para     :               MotAsp_Lib_SIG_DIAG_BASIC_STATUS *MotAsp_Lib_Obj 
                              typedef struct{
                                   MotAsp_Lib_SIG_V_RANGE_TYPE V_Range;     -The range of AD voltage values for the sin+, cos+, sin-, and cos- signals
                                   uint16 SinCos_V;                         -Acquisition AD values of sin+, cos+, sin-, and cos- signals
                                   MotAsp_Lib_CNT_STATUS SiCo_F;            -sin+, cos+, sin-, cos- signal counting structures
                              }MotAsp_Lib_SIG_DIAG_BASIC_STATUS;                            
*Return   :                                   NULL                                    
 */
 void MotAsp_Lib_Mps_SimpleFault(MotAsp_Lib_SIG_DIAG_BASIC_STATUS *MotAsp_Lib_Obj);

 /*
*Function :                                MotAsp_Lib_Mps_SiNCos_Calib             
*Brief    :     Diagnostic detection of the status of the four wires of sin,  cos,                    
*Para     :     MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS *MotAsp_Lib_Obj               
                    typedef struct{
                    MotAsp_Lib_SinCos_INFO SiCo_Diff;               -SIN and COS signals     
                    MotAsp_Lib_CNT_STATUS SiCs_DF;                  -Acquisition AD values of sin+, cos, sin,                               
                    MotAsp_Lib_SINCOS_CALIB_PARA_STATUS Limit_D;    -sin, cos signal counting structures                                              
               }MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS;                 
*Return   :                                   NULL                                 
 */
void MotAsp_Lib_Mps_SiNCos_Calib(MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS *MotAsp_Lib_Obj);

 /*
*Function :                  MotAsp_Lib_Mps_SinCos_Simp_Mid_Avg_Filter                         
*Brief    :         Sin+ and Sin-, Cos+ and Cos- signals are synthesized into Sin, CoS, and the Sin or CoS signals are obtained by backup and processing
*Para     :         MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS *MotAsp_Lib_Obj: 
                              typedef struct {
                                   sint16 Calc_Gain;                 -Sin and Cos collect and calculate the magnification or gain of the original signal
                                   uint16 Simp_Arr_CNT;              -The length of the array
                                   sint16 *Simp_Arr_Dislay;          -The pointer to the signal history data array of Sin and Cos 

                                   uint16 Limit_Calib;               -Effective limits for Sin+, Cos+, Sin-, Cos-
                                   uint16 State;                     -The signal validity status of Sin+, Cos+, Sin-, and Cos-
                                   uint16 Simp0;                     -Sin-、Cos-
                                   uint16 Simp1;                     -Sin+、Cos+
                                   sint16 Simp;                      -Sin、Cos ；For example : Simp_Sin = Gain * (Sin+ - Sin-);
                                   sint16 Simp_Last;                 -The Sin、Cos result of the last Simp
                                   uint16 Simp_Arr_Cnt;              -The length of the array
                                   sint16 FILTER;                    -The Sin、Cos current filtering results
                              }MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS;                         
*Return   :                                  NULL                                                
 */
void MotAsp_Lib_Mps_SinCos_Simp_Mid_Avg_Filter(MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS *MotAsp_Lib_Obj);


/*
*Function :                   MotAsp_Lib_Mps_SinCos_Calib_Logic                               
*Brief    :         The maximum and minimum values of sin(cos) are calculated by cos(sin), and the 
          center point and gain are calculated, and the proportional values of the current sin(cos) are obtained
*Para     :         MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS *MotAsp_Lib_Obj:   
                         typedef struct {
                         uint16 Ratio;                                      -     The value of a quarter of each circle, such as:65536 / 4 = 16384
                         MotAsp_Lib_SINCOS_LIMIT_DATA Init;                 -     The initial maximum and minimum values of sin(cos).  
                         uint16 Arr_CNT;                                    -     How much of this data is prepared is calculated after that      
                         
                         sint16 Simp;                                       -     sin(cos) is the current value of the collection                               
                         MotAsp_Lib_CALI_STATE State;                       -     Operational status                                 
                         sint16 Simp_Another;                               -     cos(sin), the signal variable used for reference by the signal under test               
                         uint16 Arr_Cnt;                                    -     The number of times the current count is counted                
                         MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS MIA;    -     Detects the maximum or minimum value of the signal's sin(cos).             
                         MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS max;  -     The maximum value of this signal sin(cos) is the PI structure             
                         MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS min;  -     The minimum value of this signal sin(cos) is the PI structure 
                         sint16 Center;                                     -     Center point  
                         sint16 Result;                                     -     The correction algorithm calculates the value of the sin(cos) signal                                      
                         }MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS;                  
*Return   :                                   NULL                                              
 */
void MotAsp_Lib_Mps_SinCos_Calib_Logic(MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS *MotAsp_Lib_Obj , MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS *MotAsp_Lib_Refer);

/*
*Function :                   MotAsp_Lib_Mps_E_Angle_Spd_Increment_Calc                                   
*Brief    :         Calculate the corresponding amount of angle accumulation as well as the velocity of the angle 
*Para     :         MotAsp_Lib_ANGLE_INCREMENT_STAUTS *MotAsp_Lib_Obj:    
                         typedef struct {
                              uint16 Degrees_180;     -     What is the value of 180°             
                              uint16 Degrees_360;     -     What is the value of 360° 

                              uint16 Calib_Angle;     -     The calculated angle                                                 
                              sint32 Incr_Angle;      -     The value that increases each time                                                             
                              sint64 Angle;           -     All angles increase and                                              
                              sint64 Last_Angle;      -     The Angle value of the last time                                                   
                              sint32 spd;             -     Angles that increase with each run                                                                            
                              }MotAsp_Lib_ANGLE_INCREMENT_STAUTS;                     
*Return   :                                  NULL                                                
 */
void MotAsp_Lib_Mps_E_Angle_Spd_Increment_Calc(MotAsp_Lib_ANGLE_INCREMENT_STAUTS *MotAsp_Lib_Obj);

/*
*Function :                   MotAsp_Lib_MPS_STAUTS                              
*Brief    :         MPS throughout the process
*Para     :         MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS *MotAsp_Lib_Obj: 
                         typedef struct {
                              MotAsp_Lib_SIG_DIAG_BASIC_STATUS D_SiCo_i[MotAsp_Lib_SIN_COS_SIG_NUM];    -    Diagnose the status of the sensor signal 
                              MotAsp_Lib_SINCOS_CALIB_BASIC_STATUS D_sic;                               -    Diagnose the status of the cos 、sin INFO    
                              MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS F_Sico[MotAsp_Lib_SiCo_NUM];  -    Differential filtering of sensor signals                                                                
                              MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS C_SiCo[MotAsp_Lib_SiCo_NUM];          -    Compensation of sensor signals                                                                    
                              MotAsp_Lib_SINCOS_TRACK_COORDINATE_STATUS Arctan;                         -    The arctangent of the sensor signal                                                           
                              MotAsp_Lib_ANGLE_INCREMENT_STAUTS Sp;                                     -    The velocity of the sensor signal as well as the position signal are calculated                                       
                              }MotAsp_Lib_MPS_STAUTS;                  
*Return   :                                   NULL                                       
 */
void MotAsp_Lib_Mps_Handler(MotAsp_Lib_MPS_STAUTS *MotAsp_Lib_Obj);

#endif



